<?php
/**********************tp controller，tp service底层相关方法工具******************************/

/**
 * dealComment function
 *
 * @Name 注解解析
 * @Desc 解析注解，可用于处理事务、接口权限、日志等数据
 * @Author Pekey
 * @Date 2020-08-12
 * @param [type] $comment 注释内容
 * @return void
 */
function dealComment($comment)
{
    $ret_data = array();
    $ret_data['name'] = "";
    $ret_data['desc'] = "";
    $ret_data['openflag'] = "";
    $ret_data['author'] = "";
    $ret_data['date'] = "";
    $str_arr = explode('*', $comment);
    foreach ($str_arr as $str) {
        if (($idx = stripos($str, '@Name')) !== false) {
            $ret_data['name'] = trim(substr($str, $idx + strlen('@Name')));
        } else if (($idx = stripos($str, '@Desc')) !== false) {
            $ret_data['desc'] = trim(substr($str, $idx + strlen('@Desc')));
        } else if (($idx = stripos($str, '@OpenFlag')) !== false) {
            $ret_data['openflag'] = trim(substr($str, $idx + strlen('@OpenFlag')));
        } else if (($idx = stripos($str, '@Author')) !== false) {
            $ret_data['author'] = trim(substr($str, $idx + strlen('@Author')));
        } else if (($idx = stripos($str, '@Date')) !== false) {
            $ret_data['date'] = trim(substr($str, $idx + strlen('@Date')));
        }
    }
    return $ret_data;
}


/**
 * de function
 *
 * @Name 注解页面模块解析
 * @Desc 解析注解，可用于control模块获取
 * @Author LiAnXu
 * @Date 2021-01-05
 * @param [type] $comment 注释内容
 * @return void
 */
function dealPageComment($comment)
{
    $model = "";
    $str_arr = explode('*', $comment);
    foreach ($str_arr as $str) {
        if (($idx = stripos($str, '@model')) !== false) {
            $model = trim(substr($str, $idx + strlen('@model')));
        } 
    }
    return $model;
}